#ifndef EGG_SHADER_H
#define EGG_SHADER_H

#include "ShaderParamMap.h"

namespace egg{

    class Shader;
    typedef shared_ptr<Shader> ShaderPtr;

    class Shader{
    public:
        Shader();
        ~Shader();
        void fromFile(const string& vs,const string& fs);
        void fromString(const string& vs,const string& fs);
        void _bindParamMap(ShaderParamMap* paramMap);
        void _unbindParamMap(ShaderParamMap* paramMap);

        inline GLuint getID(){
            return mID;
        }
        inline string getVertSource(){
            return getCompiledSource(mVertShader);
        }
        inline string getFragSource(){
            return getCompiledSource(mFragShader);
        }
    protected:
        void compileAndLink(const string& vert,const string& frag);
        void compile(GLuint shader,const string& src);
        string getCompiledSource(GLuint shader);
        void link();
    protected:
        GLuint mID;
        GLuint mVertShader;
        GLuint mFragShader;
        vector<ShaderParamMap*> mParamMaps;
    };

}

#endif